Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue-4364] add attached_images association to workflow copier #4369

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

Tooyosi
Copy link
Contributor

@Tooyosi Tooyosi commented Jul 29, 2024

Describe your change here.
Solves for this issue

Review checklist

  • First, the most important one: is this PR small enough that you can actually review it? Feel free to just reject a branch if the changes are hard to review due to the length of the diff.
  • If there are any migrations, will they the previous version of the app work correctly after they've been run (e.g. the don't remove columns still known about by ActiveRecord).
  • If anything changed with regards to the public API, are those changes also documented in the apiary.apib file?
  • Are all the changes covered by tests? Think about any possible edge cases that might be left untested.

Copy link
Collaborator

@yuenmichelle1 yuenmichelle1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall change looks ok to me. 👌🏼

It looks like
☑️ it passed the spec https://github.com/zooniverse/panoptes/blob/master/spec/lib/workflow_copier_spec.rb#L35-L38 which checks to make sure non-excluded attributes are being included.
☑️ and it passes your new spec that attached_images be included
☑️ passes the spec that any excluded attributes are set to defaults for the copied workflow.

OOC, do you know why deep_cloneable gem's #deep_clone is not including attached images? It feels like it should without us having to explicitly include it. But current behavior in panoptes has proved otherwise. 🤔 (I havent looked too much into this, but was wondering if you have.) @Tooyosi

@Tooyosi
Copy link
Contributor Author

Tooyosi commented Aug 1, 2024

Overall change looks ok to me. 👌🏼

It looks like ☑️ it passed the spec https://github.com/zooniverse/panoptes/blob/master/spec/lib/workflow_copier_spec.rb#L35-L38 which checks to make sure non-excluded attributes are being included. ☑️ and it passes your new spec that attached_images be included ☑️ passes the spec that any excluded attributes are set to defaults for the copied workflow.

OOC, do you know why deep_cloneable gem's #deep_clone is not including attached images? It feels like it should without us having to explicitly include it. But current behavior in panoptes has proved otherwise. 🤔 (I havent looked too much into this, but was wondering if you have.) @Tooyosi

Yeah, my understanding is it has to be included for it to be copied along, here: https://github.com/moiristo/deep_cloneable?tab=readme-ov-file#association-inclusion

Copy link
Collaborator

@yuenmichelle1 yuenmichelle1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super sorry I should have caught this sooner when looking through spec.

Are we certain that workflow.attached_images in spec has media (i.e. are we certain workflow.attached_images is not an empty array?) ?

I worry that the way we define media with let and how let gets lazily evaluated, that the media is actually not getting associated with the workflow until invoked (i.e. until we specifically call out media eg. puts media). Maybe let! or instead setting/creating media within the test it copies the attached_images would get media associated to workflow?

@Tooyosi
Copy link
Contributor Author

Tooyosi commented Aug 1, 2024

Super sorry I should have caught this sooner when looking through spec.

Are we certain that workflow.attached_images in spec has media (i.e. are we certain workflow.attached_images is not an empty array?) ?

I worry that the way we define media with let and how let gets lazily evaluated, that the media is actually not getting associated with the workflow until invoked (i.e. until we specifically call out media eg. puts media). Maybe let! or instead setting/creating media within the test it copies the attached_images would get media associated to workflow?

Thanks for picking this, somehow it seems like it was good originally but i can see the issue. I have moved the creation into the specific test case and checking the count as both items would not be the exact same records (i.e different id, created date e.t.c)

@Tooyosi Tooyosi requested a review from yuenmichelle1 August 1, 2024 16:45
@Tooyosi Tooyosi merged commit d27bc29 into master Aug 1, 2024
8 checks passed
@Tooyosi Tooyosi deleted the 4364-workfkow-copier-attached-images branch August 1, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A copied workflow with survey task does not show images linked to survey task
2 participants